package MyPackage;
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		
System.out.println("MyCMD start...");
Scanner inp=new Scanner(System.in);

	String dir;
		
	System.out.println("Exercise 1\n**Print directory**\nInput directory:");
	dir=inp.nextLine();
	printDir(dir);
		
System.out.println("\nMyCMD stop.");
	}
	
	public static void printDir(String dir){
		File f=new File(dir);
		if(!f.exists()){
			System.out.println("Not found directory "+f.toString());
		}
		else{
		
		System.out.println(">>> "+dir);
		String[] dirList=f.list();
		int k=0;
		String[] fileList=new String[dirList.length];
		for(int i=0;i<dirList.length;i++){
			File f1=new File(dir+File.separator+dirList[i]);
			if(!f1.isFile())System.out.println("DIR "+dirList[i]);
			else{
				fileList[k]=dirList[i];
				k++;
			}
		}
		for(int i=0;i<k;i++){
			System.out.println(fileList[i]);
		}
		}
	}

}	



